package com.hiwhitley.himei.contract.presenter;

import com.hiwhitley.himei.contract.MeituContract;
import com.hiwhitley.himei.mvpframe.rx.RxSchedulers;

import rx.schedulers.Schedulers;

/**
 * Created by hiwhitley on 2016/9/22.
 */

public class MeituPresenter extends MeituContract.Presenter {
    @Override
    public void loadBenefit(int page) {
        mRxManager.add(mModel.getBenefit(page)
                .subscribeOn(Schedulers.io())
                .doOnSubscribe(() -> mView.onRequestStart())
                .compose(RxSchedulers.io_main())
                .subscribe(
                        benefit -> mView.showMeitus(benefit.getResults()),
                        throwable -> {
                            mView.onInternetError();
                            mView.onRequestEnd();
                        }
                )
        );
    }
}
